package cn.it.controller;

import cn.it.constant.MessageConstant;
import cn.it.entity.PageResult;
import cn.it.entity.QueryPageBean;
import cn.it.entity.Result;
import cn.it.pojo.User;
import cn.it.service.MainService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/main")
@RestController
public class MainController {

    @Reference
    private MainService mainService;

    @RequestMapping(value = "/findPage", name = "用户信息分页查询")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
     return mainService.pageQuery(queryPageBean);
    }

    @RequestMapping(value = "/add",name = "添加用户")
    public Result add(@RequestBody User user,Integer[] roleIds ){
        try {
            mainService.add(user,roleIds);
            return  new Result(true, "添加用户成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"添加用户失败");
        }
    }


}
